All Questions
44 questions
8votes
5answers
1kviews
Expanding powers of expressions of the form ax+b
I solved the following problem: Write a function expand that takes in an expression with a single, one character variable, and expands it. The expression is in the form ...
3votes
1answer
1kviews
Shortest way to form a string out of a subsequence of a string
The task is taken from LeetCode (subscription required) - From any string, we can form a subsequence of that string by deleting some number of characters (possibly no deletions). Given two strings ...
6votes
4answers
3kviews
Find all letter Combinations of a Phone Number
The task is taken from LeetCode Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. A mapping of digit to letters (just ...
2votes
1answer
757views
Given time intervals determine if a person could attend all meetings
The task is taken from LeetCode Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] ...
5votes
1answer
8kviews
Merge Two Sorted Lists in JavaScript
The task is taken from LeetCode Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. Example 1: ...
8votes
1answer
2kviews
Merge Intervals in JavaScript
This is a task taken from Leetcode - Given a collection of intervals, merge all overlapping intervals. Example 1: ...
1vote
3answers
545views
Jewels and Stones
The task is taken from leetcode You're given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have....
5votes
1answer
323views
Find the starting indices of all occurrences of the pattern in the string - KMP algorithm follow-up
The task was initially solved here, but was too buggy: Given a string and a pattern, find the starting indices of all occurrences of the pattern in the string. For example, given the string "...
2votes
1answer
266views
Number of Islands
The task is taken from leetcode Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands ...
2votes
1answer
477views
Length of the longest consecutive run of 1s in its binary representation
The task Given an integer n, return the length of the longest consecutive run of 1s in its binary representation. For example, given 156, you should return 3 My function solution 1 Style 1 <...
3votes
1answer
633views
Longest Consecutive Sequence
This task is taken from Leetcode - Given an unsorted array of integers, find the length of the longest consecutive elements sequence. Your algorithm should run in \$O(n)\$ complexity. ...
1vote
1answer
138views
Daily Temperatures
The task is taken from leetcode Given a list of daily temperatures T, return a list such that, for each day in the input, tells you how many days you would have to wait until a warmer ...
4votes
1answer
1kviews
Encode and Decode TinyURL
The task is taken from leetcode TinyURL is a URL shortening service where you enter a URL such as https://leetcode.com/problems/design-tinyurl and it returns a short URL such as http://tinyurl....
4votes
2answers
378views
Find out whether number is of Power of Two
The task is taken from leetcode Given an integer, write a function to determine if it is a power of two. Example 1: Input: 1 Output: true Explanation: 20 = 1 Example 2: ...
1vote
1answer
3kviews
Reverse Vowels of a String
The task is taken from leetcode Write a function that takes a string as input and reverse only the vowels of a string. Example 1: Input: "hello" Output: "holle" Example 2: ...